package com.common.rabbitmq.producer.core;

import com.common.handler.ExchangeServiceHandler;
import com.common.rabbitmq.producer.AbstractProducer;
import org.springframework.stereotype.Component;

@Component
public class OrderProducer extends AbstractProducer {
    private static final String defaultExchange = ExchangeServiceHandler.ORDER_EXCHANGE;
    private static final String deadLetterExchange = ExchangeServiceHandler.ORDER_TASK_EXCHANGE;

    @Override
    public String getExchange() {
        return defaultExchange;
    }

    @Override
    public String getDeadLetterExchange() {
        return deadLetterExchange;
    }

    /**
     * 订单支付成功
     */
    public void orderPaySuccess(String orderNo){
        send("order.pay.success", orderNo);
    }

    /**
     * 订单退款成功
     */
    public void orderRefundSuccess(String orderNo){
        send("order.refund.success", orderNo);
    }
    /**
     * 订单退款失败
     */
    public void orderRefundFail(String orderNo){
        send("order.refund.fail", orderNo);
    }

    /**
     * 定时任务 =》校验订单
     * @param orderId
     */
    public void orderClickTask(Long orderId){
        sendDelay("order.check.task", orderId, 1000 * 10);
    }
}
